package com.itheima.store.controller;

import com.itheima.store.entity.Category;
import com.itheima.store.service.CategoryService;
import com.itheima.store.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @RequestMapping("category")
    @ResponseBody
    public Result findAll(){
        List<Category> categoryList = categoryService.findAll();
        if(categoryList != null){
            return new Result(Result.SUCCESS,"成功",categoryList);
        }
        return new Result(Result.FAILS,"失败", null);
    }

}
